#include    "reservoir.h"

//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
Reservoir::Reservoir(double volume, QObject *parent) : BrakeDevice(parent)
    , V(volume)
    , Q(0.0)
    , k_flow(0.0)
{

}

//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
Reservoir::~Reservoir()
{

}

//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
void Reservoir::setAirFlow(double Q)
{
    this->Q = Q;
}

//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
void Reservoir::setFlowCoeff(double coeff)
{
    k_flow = coeff;
}

//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
double Reservoir::getPressure() const
{
    return getY(0);
}

//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
void Reservoir::ode_system(const state_vector_t &Y, state_vector_t &dYdt, double t)
{
   Q_UNUSED(t)   

   dYdt[0] = (Q - k_flow * Y[0]) / V;
}
